<?php
/* SVN FILE: $Id: cp_skin_logs.php 158 2009-08-13 18:28:08Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* ibMarket ACP logs html
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 158 $
* @lastrevision $Date: 2009-08-13 18:28:08 +0000 (Thu, 13 Aug 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-08-13 18:28:08 +0000 (Thu, 13 Aug 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/skin_cp/cp_skin_logs.php $
*/

class cp_skin_logs extends output
{

/**
 * Prevent our main destructor being called by this class
 *
 * @access	public
 * @return	void
 */
public function __destruct()
{
}

/**
 * Listing all the receipts
 *
 * @access	public
 * @return	string	HTML
 */
public function logReceipts( array $receipts, $links ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['log_receipt_title']}</h2>
</div>

<div id='catgories'>
	<div class='acp-box'>
		<h3>{$this->lang->words['log_receipt_table']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['ip_address']}</th>
				<th style='white-space:nowrap'>{$this->lang->words['log_receipt_member']}</th>
				<th style='white-space:nowrap'>{$this->lang->words['log_receipt_time']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_receipt_method']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_receipt_items']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_receipt_total']}</th>
			</tr>

EOF;
foreach($receipts as $receipt)
{
	$member = marketFormatter::formatName(array('member_id'=>$receipt['member_id'], 'members_display_name'=>$receipt['members_display_name'], 'member_group_id'=>$receipt['member_group_id']));
	$time = $this->registry->getClass('class_localization')->getDate( $receipt['time_bought'], 'LONG' );
	$receipt['total_quanity'] = $this->registry->getClass('class_localization')->formatNumber($receipt['total_quanity']);
	$receipt['total_money'] = marketFormatter::formatCurrency($receipt['method'] == 'buy' ? $receipt['total_price'] : $receipt['total_resell']);
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$receipt['ip_address']}</td>
				<td style='white-space:nowrap'>{$member}</td>
				<td style='white-space:nowrap'>{$time}</td>
				<td style='white-space:nowrap'>{$this->lang->words['log_receipt_method_'.$receipt['method']]}</td>
				<td style='white-space:nowrap'>{$receipt['total_quanity']}</td>
				<td style='white-space:nowrap'>{$receipt['total_money']}</td>
			</tr>

EOF;
}
if(count($receipts) == 0)
{
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap; text-align:center' colspan='6'><strong>{$this->lang->words['log_receipt_none']}</strong></td>
			</tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
		<div class='acp-actionbar'>
			<div class="leftaction">{$links}</div>
		</div>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Listing all the item logs
 *
 * @access	public
 * @return	string	HTML
 */
public function logItems( array $logs, $links ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['log_item_title']}</h2>
</div>

<div id='catgories'>
	<div class='acp-box'>
		<h3>{$this->lang->words['log_item_table']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_item_item']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['ip_address']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_item_member']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_item_time']}</th>
				<th style='white-space:nowrap'>{$this->lang->words['log_item_message']}</th>
			</tr>

EOF;
foreach($logs as $log)
{
	$member = marketFormatter::formatName(array('member_id'=>$log['member_id'], 'members_display_name'=>$log['members_display_name'], 'member_group_id'=>$log['member_group_id']));
	$time = $this->registry->getClass('class_localization')->getDate( $log['l_time'], 'LONG' );
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$this->caches['market_items'][$log['item_id']]['item_name']}</td>
				<td style='white-space:nowrap'>{$log['ip_address']}</td>
				<td style='white-space:nowrap'>{$member}</td>
				<td style='white-space:nowrap'>{$time}</td>
				<td>{$log['log_message']}</td>
			</tr>

EOF;
}
if(count($logs) == 0)
{
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap; text-align:center' colspan='6'><strong>{$this->lang->words['log_item_none']}</strong></td>
			</tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
		<div class='acp-actionbar'>
			<div class="leftaction">{$links}</div>
		</div>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Listing all the rewards
 *
 * @access	public
 * @return	string	HTML
 */
public function logReward( array $logs, $links ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['log_reward_title']}</h2>
</div>

<div id='catgories'>
	<div class='acp-box'>
		<h3>{$this->lang->words['log_reward_table']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_reward_member']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_reward_time']}</th>
				<th style='white-space:nowrap'>{$this->lang->words['log_reward_location_reason']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_reward_amount']}</th>
			</tr>

EOF;
foreach($logs as $log)
{
	$member = marketFormatter::formatName(array('member_id'=>$log['member_id'], 'members_display_name'=>$log['members_display_name'], 'member_group_id'=>$log['member_group_id']));
	$time = $this->registry->getClass('class_localization')->getDate( $log['l_time'], 'LONG' );
	$amount = marketFormatter::formatCurrency($log['l_amount']);
	$reason = "";
	if($log['location'] == 'registered')
	{
		$reason = $this->lang->words['log_reward_registration_bonus'];
	}
	elseif($log['location'] == 'posts')
	{
		$reason = $this->lang->words['log_reward_post_rewards'];
	}
	elseif(strstr($log['location'],'plugin:') === $log['location'])
	{
		$info = explode(":",$log['location']);
		if(is_array($this->caches['market_plugin'][$info[1]]))
		{
			$info[2] = $this->caches['market_plugin'][$info[1]]['name'];
		}
		$reason = sprintf($this->lang->words['log_reward_from_plugin'], $info[2]);
	}
	elseif(strstr($log['location'],'item:') === $log['location'])
	{
		$info = explode(":",$log['location']);
		if(is_array($this->ipsclass->cache['market_items'][$info[1]]))
		{
			$info[2] = $this->ipsclass->cache['market_items'][$info[1]]['item_name'];
		}
		$reason = sprintf($this->lang->words['log_reward_from_item'], $info[2]);
	}
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$member}</td>
				<td style='white-space:nowrap'>{$time}</td>
				<td style='white-space:nowrap'>{$reason}</td>
				<td style='white-space:nowrap'>{$amount}</td>
			</tr>

EOF;
}
if(count($logs) == 0)
{
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap; text-align:center' colspan='6'><strong>{$this->lang->words['log_reward_none']}</strong></td>
			</tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
		<div class='acp-actionbar'>
			<div class="leftaction">{$links}</div>
		</div>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Listing all the fees
 *
 * @access	public
 * @return	string	HTML
 */
public function logFee( array $logs, $links ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['log_fee_title']}</h2>
</div>

<div id='catgories'>
	<div class='acp-box'>
		<h3>{$this->lang->words['log_fee_table']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_fee_member']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_fee_time']}</th>
				<th style='white-space:nowrap'>{$this->lang->words['log_fee_location_reason']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['log_fee_amount']}</th>
			</tr>

EOF;
foreach($logs as $log)
{
	$member = marketFormatter::formatName(array('member_id'=>$log['member_id'], 'members_display_name'=>$log['members_display_name'], 'member_group_id'=>$log['member_group_id']));
	$time = $this->registry->getClass('class_localization')->getDate( $log['l_time'], 'LONG' );
	$amount = marketFormatter::formatCurrency($log['l_amount']);
	$reason = "";
	if($log['location'] == 'buy')
	{
		$reason = $this->lang->words['log_fee_item_tax'];
	}
	elseif(strstr($log['location'],'plugin:') === $log['location'])
	{
		$info = explode(":",$log['location']);
		if(is_array($this->caches['market_plugin'][$info[1]]))
		{
			$info[2] = $this->caches['market_plugin'][$info[1]]['name'];
		}
		$reason = sprintf($this->lang->words['log_fee_from_plugin'], $info[2]);
	}
	elseif(strstr($log['location'],'item:') === $log['location'])
	{
		$info = explode(":",$log['location']);
		if(is_array($this->ipsclass->cache['market_items'][$info[1]]))
		{
			$info[2] = $this->ipsclass->cache['market_items'][$info[1]]['item_name'];
		}
		$reason = sprintf($this->lang->words['log_fee_from_item'], $info[2]);
	}
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$member}</td>
				<td style='white-space:nowrap'>{$time}</td>
				<td style='white-space:nowrap'>{$reason}</td>
				<td style='white-space:nowrap'>{$amount}</td>
			</tr>

EOF;
}
if(count($logs) == 0)
{
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap; text-align:center' colspan='6'><strong>{$this->lang->words['log_fee_none']}</strong></td>
			</tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
		<div class='acp-actionbar'>
			<div class="leftaction">{$links}</div>
		</div>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Listing all the taxes collected
 *
 * @access	public
 * @return	string	HTML
 */
public function logTax( array $logs, $links ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['log_tax_title']}</h2>
</div>

<div id='catgories'>
	<div class='acp-box'>
		<h3>{$this->lang->words['log_tax_table']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_tax_member']}</th>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_tax_time']}</th>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_tax_amount']}</th>
			</tr>

EOF;
foreach($logs as $log)
{
	$member = marketFormatter::formatName(array('member_id'=>$log['member_id'], 'members_display_name'=>$log['members_display_name'], 'member_group_id'=>$log['member_group_id']));
	$time = $this->registry->getClass('class_localization')->getDate( $log['l_time'], 'LONG' );
	$amount = marketFormatter::formatCurrency($log['l_amount']);
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$member}</td>
				<td style='white-space:nowrap'>{$time}</td>
				<td style='white-space:nowrap'>{$amount}</td>
			</tr>

EOF;
}
if(count($logs) == 0)
{
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap; text-align:center' colspan='6'><strong>{$this->lang->words['log_tax_none']}</strong></td>
			</tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
		<div class='acp-actionbar'>
			<div class="leftaction">{$links}</div>
		</div>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Listing all the wages collected by member
 *
 * @access	public
 * @return	string	HTML
 */
public function logWageMember( array $logs, $links ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['log_wage_title']}</h2>
</div>

<div id='catgories'>
	<div class='acp-box'>
		<h3>{$this->lang->words['log_wage_table']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_wage_member']}</th>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_wage_time']}</th>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_wage_amount']}</th>
			</tr>

EOF;
foreach($logs as $log)
{
	$member = marketFormatter::formatName(array('member_id'=>$log['id_who'], 'members_display_name'=>$log['members_display_name'], 'member_group_id'=>$log['member_group_id']));
	$time = $this->registry->getClass('class_localization')->getDate( $log['time_collected'], 'LONG' );
	$amount = marketFormatter::formatCurrency($log['how_much']);
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$member}</td>
				<td style='white-space:nowrap'>{$time}</td>
				<td style='white-space:nowrap'>{$amount}</td>
			</tr>

EOF;
}
if(count($logs) == 0)
{
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap; text-align:center' colspan='6'><strong>{$this->lang->words['log_wage_none']}</strong></td>
			</tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
		<div class='acp-actionbar'>
			<div class="leftaction">{$links}</div>
		</div>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Listing all the wages collected by member
 *
 * @access	public
 * @return	string	HTML
 */
public function logWageGroup( array $logs, $links ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['log_wage_title']}</h2>
</div>

<div id='catgories'>
	<div class='acp-box'>
		<h3>{$this->lang->words['log_wage_table']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_wage_group']}</th>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_wage_time']}</th>
				<th style='width:1px;min-width:33%;white-space:nowrap'>{$this->lang->words['log_wage_amount']}</th>
			</tr>

EOF;
foreach($logs as $log)
{
	$group = $this->caches['group_cache'][$log['id_who']]['prefix'].$this->caches['group_cache'][$log['id_who']]['g_title'].$this->caches['group_cache'][$log['id_who']]['suffix'];
	$time = $this->registry->getClass('class_localization')->getDate( $log['time_collected'], 'LONG' );
	$amount = marketFormatter::formatCurrency($log['how_much']);
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$group}</td>
				<td style='white-space:nowrap'>{$time}</td>
				<td style='white-space:nowrap'>{$amount}</td>
			</tr>

EOF;
}
if(count($logs) == 0)
{
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap; text-align:center' colspan='6'><strong>{$this->lang->words['log_wage_none']}</strong></td>
			</tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
		<div class='acp-actionbar'>
			<div class="leftaction">{$links}</div>
		</div>
	</div>
</div>

EOF;

return $IPBHTML;
}

}